import Vue from 'vue'
import App from './App'
import store from './store'
import router from './router'
// import VueAMap from 'vue-amap'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './assets/styles/element-variables.scss'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/infocollect.scss' // infocollect css
import permission from './directive/permission'

import './assets/icons' // icon
// import '@/icons/index.js' // icon
import './permission' // permission control
import './components/antDesignComp/index' // ant组件
// import { getDicts } from "@/api/system/dict/data";
// import { getConfigKey } from "@/api/system/config";
// import { parseTime, resetForm, addDateRange, selectDictLabel, download, handleTree } from "@/utils/infocollect";
// import Pagination from "@/components/Pagination";
import { ajaxComm, getNewId } from '@/api/index'

import swal from 'sweetalert';

// import i18n from './lang'
// 全局方法挂载
//Vue.prototype.getDicts = getDicts
// Vue.prototype.getConfigKey = getConfigKey
// Vue.prototype.parseTime = parseTime
// Vue.prototype.resetForm = resetForm
// Vue.prototype.addDateRange = addDateRange
// Vue.prototype.selectDictLabel = selectDictLabel
// Vue.prototype.download = download
// Vue.prototype.handleTree = handleTree


Vue.config.productionTip = false
Vue.prototype.$apiComm = ajaxComm
//Vue.prototype.$ajaxswagger = ajaxswagger
Vue.prototype.$getNewId = getNewId
Vue.prototype.$user = store
function queryUrlParam(queryName) {
  // const query = decodeURI(window.location.href.substring(1))
  // const vars = query.split('&')
  // for (let i = 0; i < vars.length; i++) {
  //   const pair = vars[i].split('=')
  //   if (pair[0] === queryName) {
  //     return pair[1]
  //   }
  // }
  // return null
  var reg = new RegExp("(^|&)" + queryName + "=([^&]*)(&|$)", "i");
  var r = window.location.search.substring(1).match(reg);
  if (r != null) return decodeURI(unescape(r[2])); return null;
}
Vue.prototype.$query = queryUrlParam

Vue.prototype.msgSuccess = function (msg) {
  this.$message({ showClose: true, message: msg, type: "success" });
}

Vue.prototype.msgError = function (msg) {
  this.$message({ showClose: true, message: msg, type: "error" });
}

Vue.prototype.msgInfo = function (msg) {
  this.$message.info(msg);
}

// 全局组件挂载
// Vue.component('Pagination', Pagination)

Vue.use(permission)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

Vue.config.productionTip = false

// new Vue({
//   el: '#app',
//   router,
//   store,
//   render: h => h(App)
// })
function render() {
  new Vue({
    router,
    store,
    // i18n,
    render: h => h(App)
  }).$mount('#app')
}
render()
